package pro.shushi.pamirs.hr.api.model.biz;

import pro.shushi.pamirs.boot.base.ux.annotation.field.UxWidget;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxForm;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxTableSearch;
import pro.shushi.pamirs.hr.api.enums.ApprovalStatusEnum;
import pro.shushi.pamirs.hr.api.model.org.Corporation;
import pro.shushi.pamirs.meta.annotation.Field;
import pro.shushi.pamirs.meta.annotation.Model;
import pro.shushi.pamirs.meta.base.common.CodeModel;

import java.math.BigDecimal;
import java.util.List;

// 模型中UX开头的注解(UxForm/UxTable/UxDetail等)可以不用写，都可在设计器中进行可视化配置; 代码里面写这些注解是为了默认页面的交互
@Model.model(ExpenseBill.MODEL_MODEL)
@Model(displayName = "报销单")
@Model.Code(sequence = "SEQ", prefix = "BX", size = 5, step = 1, initial = 10000)
@Model.Advanced(index = {"submitter","corporationCode"})
public class ExpenseBill extends CodeModel {

    public static final String MODEL_MODEL = "hr.simple.ExpenseBill";

    @UxTableSearch.FieldWidget(@UxWidget())
    @UxForm.FieldWidget(@UxWidget(readonly = "true", hint = "为空时自动生成"))
    @Field(displayName = "编码", unique = true)
    private String code;

    @UxTableSearch.FieldWidget(@UxWidget())
    @Field(displayName = "提交人", required = true)
    public String submitter;

    @Field.many2one
    @Field.Relation(relationFields = {"corporationCode"}, referenceFields = {"code"})
    @Field(displayName = "所属公司", required = true)
    private Corporation corporation;

    @Field(displayName = "所属公司编码", invisible = true)
    private String corporationCode;

    @Field.Money(M = 11,D = 2)
    @Field(displayName = "报销总金额", required = true)
    private BigDecimal amount;

    @Field(displayName = "收款银行", required = true)
    private String receivingBank;

    @Field(displayName = "收款账号", required = true)
    private String bankAccountNumber;

    @Field.Enum
    @Field(displayName = "审批状态", defaultValue = "NC")
    @UxForm.FieldWidget(@UxWidget(invisible = "true"))
    private ApprovalStatusEnum approvalStatus;

    @Field.Text
    @Field(displayName = "备注")
    private String remark;

    @Field.one2many
    @Field.Relation(relationFields = {"code"}, referenceFields = {"billCode"})
    @Field(displayName = "报销明细", required = true)
    private List<ExpenseBillDetail> billDetails;
}
